<%@ page import="java.util.List" %>
<%@ page import="pojo.OrderItem" %><%--
  Created by IntelliJ IDEA.
  User: 郝龙飞
  Date: 2021/5/28
  Time: 7:45
  To change this template use File | Settings | File Templates.
--%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>订单详情</title>
    <%--静态包含 base标签 css样式 jQuery文件--%>
    <%@include file="/pages/common/head.jsp" %>
    <style type="text/css">
        h1 {
            text-align: center;
            margin-top: 200px;
        }
    </style>
</head>
<body>

<div id="header">
    <img class="logo_img" alt="" src="/pages/static/img/logo.gif">
    <span class="wel_word">订单详情</span>
    <%--静态包含，登陆成功后的菜单--%>
    <%@include file="/pages/common/login_success_menu.jsp" %>
</div>

<%--计算每个订单项的图书个数--%>
<%
    List<OrderItem> orderItems = (List<OrderItem>) request.getSession().getAttribute("orderItems");
    int totalCount = 0;
    for (OrderItem orderItem : orderItems) {
        totalCount += orderItem.getCount();
    }
    pageContext.setAttribute("totalCount", totalCount);
%>

<div id="main">

    <table>
        <c:if test="${param.m ==1 }">
            <tr>
                <td>用户名</td>
                <td style="color: chocolate">${param.username}</td>
            </tr>
        </c:if>
        <tr>
            <td>商品名称</td>
            <td>数量</td>
            <td>单价</td>
            <td>总价</td>
            <td>状态</td>
            <td>订单号</td>
        </tr>
        <c:forEach items="${sessionScope.orderItems}" var="i">
            <tr>
                <td>${i.name}</td>
                <td>${i.count}</td>
                <td>${i.price}</td>
                <td>${i.totalPrice}</td>
                <td>
                    <c:if test="${param.status == 0}">未发货</c:if>
                    <c:if test="${param.status == 1}">已发货，运输中</c:if>
                    <c:if test="${param.status == 2}">已签收</c:if>
                </td>
                <td>${i.orderId}</td>
            </tr>
        </c:forEach>
        <br/>
        <br/>
        <br/>
        <tr>
            <c:if test="${param.m ==1 }">
                <td>商品发货状态</td>
            </c:if>
            <c:if test="${empty param.m}">
                <td>商品发货状态</td>
            </c:if>
            <c:if test="${param.m ==1 }">
                <td>
                    <c:if test="${param.status == 0}">
                        <a href="orderServlet?action=sendOrder&orderId=${param.orderId}">点击发货</a>
                    </c:if>
                    <c:if test="${param.status == 1}">已发货，运输中</c:if>
                    <c:if test="${param.status == 2}">已签收</c:if>
                </td>
            </c:if>
            <c:if test="${empty param.m}">
                <td>
                    <c:if test="${param.status == 0}">已下单，请耐心等待发货</c:if>
                    <c:if test="${param.status == 1}">
                        <a href="orderServlet?action=receiveOrder&orderId=${param.orderId}">点击签收</a>
                    </c:if>
                    <c:if test="${param.status == 2}">已签收</c:if>
                </td>
            </c:if>
        </tr>
    </table>


</div>

<%--静态包含 页脚内容--%>
<%@include file="/pages/common/footer.jsp" %>
</body>
</html>
